#!/bin/bash
export ROOTPATH=`pwd`/root
export ROOTPATH=`readlink -m $ROOTPATH`

if [ ! -d "$ROOTPATH" ]; then
    mkdir -p $ROOTPATH
fi

echo export ROOTPATH=$ROOTPATH > $ROOTPATH/environment
echo setenv ROOTPATH $ROOTPATH > $ROOTPATH/environment.csh
cat environment >> $ROOTPATH/environment
cat environment.csh >> $ROOTPATH/environment.csh

if [ ! -f PYTHON_INSTALLED ] 
then
	mkdir ctmp
	pushd ctmp
# ----------------------------------------------------------
#
# Python installation
#
	wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz 
	tar xzf Python-2.7.3.tgz
	pushd Python-2.7.3
	./configure --prefix=${ROOTPATH} --libdir=${ROOTPATH}/lib
	make
	make install
	popd
# ----------------------------------------------------------
	popd
	rm -rf ctmp
	touch PYTHON_INSTALLED
fi

. $ROOTPATH/environment
# ----------------------------------------------------------
#
# Installing basic environment
#
pushd bootstrap
python install.py
popd
# ----------------------------------------------------------
#
# Installing cosmicstrings
#
pushd cosmicstrings
python install.py
popd
# ----------------------------------------------------------
#
# Installing dalib
#
pushd dalib
python install.py
popd


